package com.mmall.concurrency.example.Singleton;

import com.mmall.concurrency.annoations.NotThreadSafe;
import com.mmall.concurrency.annoations.ThreadSafe;

/**
 * 饿汉模式
 * 单例实例在类装载时进行创建
 */
@ThreadSafe
public class SingleExample2 {

    //私有构造函数
    private SingleExample2(){

    }

    //单例对象
    private static SingleExample2 instance = new SingleExample2();

    //静态工厂方法
    public static SingleExample2 getInstance(){
        return instance;
    }

}
